exports.getErr = function(err = '服务器挂了',errCode = 500){
    return {
        code:errCode,
        msg:err
    }
}

exports.getResult = function(result,msg = '操作成功'){
    return {
        code:200,
        msg:msg,
        data:result
    }
}

exports.asyncHandle = (handler) =>{
    return async (req,res,next)=>{
        try{
            const result = await handler(req,res,next)
            res.send(exports.getResult(result))
        }catch(err){
            next(err)
        }
    }
}